<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.hs.pre.model.PreEntry" %>
<%@ page import="com.hs.pre.page.PageUtil" %>
<%@ page import="com.hs.utils.*" %> 
<%@ page import="com.hs.core.db.*" %>
<%@ page import="com.hs.*" %>
<%

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
PreEntry entry = (PreEntry)request.getAttribute("entry");
String refresh = (String)request.getAttribute("refresh");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>"> 
    <title>方泉信息服务平台-方剂编辑</title> 
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page"> 
	<script src='<%=basePath%>app/js/json.js'></script>
    <script src='<%=basePath%>dwr/interface/manager.js'></script>
    <script src='<%=basePath%>dwr/engine.js'></script>
    <script src='<%=basePath%>dwr/util.js'></script> 
   
	<style type="text/css">
        table {
            border: 1px solid black;
            border-collapse: collapse;
        }
        
        table thead tr th {
            border: 1px solid black;
            padding: 3px;
            background-color: #cccccc;
        }
        
        table tbody tr td {
            border: 1px solid black;
            padding: 3px;
        }
    </style>
	<script type="text/javascript">
	//保存方剂
	function savePre(){ 
	   var dataStr = '';
	   var fangm = dwr.util.getValue("fangm");
	   var id = dwr.util.getValue("id");
	   var biem = dwr.util.getValue("biem");
	   var chufly = dwr.util.getValue("chufly");
	   var yaowzc = dwr.util.getValue("yaowzc");
	   var jiaj = dwr.util.getValue("jiaj");
	   var gongx = dwr.util.getValue("gongx");
	   var zhuz = dwr.util.getValue("zhuz");
	   var zhibff = dwr.util.getValue("zhibff");
	   var yongfyl = dwr.util.getValue("yongfyl");
	   var yongyjj = dwr.util.getValue("yongyjj");
	   var lincyy = dwr.util.getValue("lincyy");
	   
	   var yaolzy = dwr.util.getValue("yaolzy");
	   var gejls = dwr.util.getValue("gejls");
	   var beiz = dwr.util.getValue("beiz");
	   var preId = dwr.util.getValue("preId"); 
	   var data = {"key":"key","test":"test"};
	   if(!validateNull(fangm)){ 
	      dataStr += 'fangm:'+fangm + ',';
	   }else{
	      alert('方剂名称不能为空');
	      return;
	   }
	   if(!validateNull(id)){ 
	      dataStr += 'id:'+id + ',';
	   }else{
	      alert('方剂编号不能为空');
	      return;
	   }
	   if(!validateNull(biem)){
	      dataStr += 'biem:'+biem + ',';
	   }
	   if(!validateNull(chufly)){
	       dataStr += 'chufly:'+chufly + ',';
	   }
	   if(!validateNull(yaowzc)){
	       dataStr += 'yaowzc:'+yaowzc + ',';
	   }
	   if(!validateNull(jiaj)){
	       dataStr += 'jiaj:'+jiaj + ',';
	   }
	   if(!validateNull(gongx)){
	      dataStr += 'gongx:'+gongx + ',';
	   }
	   if(!validateNull(zhuz)){
	       dataStr += 'zhuz:'+zhuz + ',';
	   }
	   if(!validateNull(zhibff)){
	       dataStr += 'zhibff:'+zhibff + ',';
	   }
	   if(!validateNull(yongfyl)){
	       dataStr += 'yongfyl:'+yongfyl + ',';
	   }
	   if(!validateNull(yongyjj)){
	       dataStr += 'yongyjj:'+yongyjj + ',';
	   }
	   if(!validateNull(lincyy)){
	       dataStr += 'lincyy:'+lincyy + ',';
	   }
	   if(!validateNull(yaolzy)){
	       dataStr += 'yaolzy:'+yaolzy + ',';
	   }
	   if(!validateNull(gejls)){
	       dataStr += 'gejls:'+gejls + ',';
	   }
	   if(!validateNull(beiz)){
	       dataStr += 'beiz:'+beiz + ',';
	   }
	   if(!validateNull(preId)){
	       dataStr += 'preId:'+preId + ',';
	   }
	   if(dataStr.length > 1){
	   		dataStr = dataStr.substring(0,dataStr.length-1);
	   }
	   dataStr +=''; 
	  // alert(dataStr);
	  // alert(eval('['+dataStr+']'));
	  // var ss = eval('['+dataStr+']');
	  // var tmp = "{"my":"tttt","test":"rrrr"}";
	   //manager.editPre(eval(tmp),functionCallBack);
	   manager.editPre(dataStr,functionCallBack)
	}
	function functionCallBack(data){
	   alert(data);
	}
	function validateNull(str){  
	    if(null == str || '' == str || ' '== str)
	       return true; 
	    return false;
	}
	function submitForm(){
	    var fangm = dwr.util.getValue("fangm");
	    var id = dwr.util.getValue("id");
	     if(validateNull(fangm)){  
	      alert('方剂名称不能为空');
	      return;
	   }
	   if(validateNull(id)){  
	      alert('方剂编号不能为空');
	      return;
	   } 
	   manager.validatePreId(id,funcCallBack); 
	}
	function funcCallBack(message){ 
		if(''!=message){ 
	   		dwr.util.setValue("alertMessage",message);
	   		}
	   else {
	   		form1.submit();
	   		}
	}
	</script>
  </head>
  <body>
  <center>
<form name="form1" action="<%=path%>/admin/manage.do?action=save" method="post">
<table cellSpacing=0 align=right cellPadding=0 border=0 width="100%">
<tr height="5px"><td colspan=4><br><br>方剂编辑&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="alertMessage"></span></td></tr>
<tr>
<td width="20%"> 
方剂编号
</td>
<td width="30%">
<input type="text" value="<%=entry==null?"":entry.getId() %>" name="id" size="60">
<input type="hidden" value="<%=entry==null?"":entry.getPreId() %>" name="preId" >
</td>
<td width="20%">
索引更新
</td>
<td>
<select name="indexType">
<option value="1" >立即执行</option>
<option value="2">定时执行</option>
<option value="3">批量执行</option>
</select>
</td>
</tr> 
<tr>
<td width="20%">
方名
</td>
<td width="30%">
<input type="text" value="<%=entry==null?"":entry.getFangm() %>" name="fangm" size="60">
</td>
<td width="20%">
别名
</td>
<td>
<input type="text" value="<%=entry==null?"":entry.getBiem() %>" name="biem" size="60">
</td>
</tr> 
<tr>
<td width="20%">
处方来源
</td>
<td width="30%">
<input type="text" value="<%=entry==null?"":entry.getChufly() %>" name="chufly" size="60">
</td>
<td width="20%">
加减
</td>
<td>
<input type="text" value="<%=entry==null?"":entry.getJiaj() %>" name="jiaj" size="60">
</td>
</tr> 
 
<tr>
<td width="20%">
功效
</td>
<td width="30%">
<textarea name="gongx" cols="45" rows="5"><%=entry==null?"":entry.getGongx() %></textarea>
</td>
<td width="20%">
药物组成
</td>
<td>
<textarea name="yaowzc" cols="45" rows="5"><%=entry==null?"":entry.getYaowzc() %></textarea>
</td>
</tr> 
<tr>
<td width="20%">
主治
</td>
<td width="30%">
<textarea name="zhuz" cols="45" rows="5"><%=entry==null?"":entry.getZhuz() %></textarea>
</td>
<td width="20%">
制备方法
</td>
<td>
<textarea name="zhibff" cols="45" rows="5"><%=entry==null?"":entry.getZhibff() %></textarea>
</td>
</tr> 

<tr>
<td width="20%">
用法用量
</td>
<td width="30%">
<textarea name="yongfyl" cols="45" rows="5"><%=entry==null?"":entry.getYongfyl() %></textarea>
</td>
<td width="20%">
用药禁忌
</td>
<td>
<textarea name="yongyjj" cols="45" rows="5"><%=entry==null?"":entry.getYongyjj() %></textarea>
</td>
</tr> 
<tr>
<td width="20%">
临床应用
</td>
<td width="30%">
<textarea name="lincyy" cols="45" rows="5"><%=entry==null?"":entry.getLincyy() %></textarea>
</td>
<td width="20%">
药理作用
</td>
<td>
<textarea name="yaolzy" cols="45" rows="5"><%=entry==null?"":entry.getYaolzy() %></textarea>
</td>
</tr> 
<tr>
<td width="20%">
各家论述
</td>
<td width="30%">
<textarea name="gejls" cols="45" rows="5"><%=entry==null?"":entry.getGejls() %></textarea>
</td>
<td width="20%">
备注
</td>
<td>
<textarea name="beiz" cols="45" rows="5"><%=entry==null?"":entry.getBeiz() %></textarea>
</td>
</tr> 
<tr>
<td colspan=2 align="right"><input   type="button" class="buttom"  onclick="submitForm();"  value="保存"></td>
<td colspan=2><input name="button" type="button" class="buttom"  onclick="window.close();" value="关闭"></td>
 
</tr>
</table>      
</form>
    </center> 
  </body>
</html>
<%if(null != refresh){ %>
 <script>
  window.opener.document.location.reload();
 </script>
<% }%>
